home *** CD-ROM | disk | FTP | other *** search
- /*
- File: FrazAPI.h
-
- Fragmalyzer Plug-in Interface
-
- Version: 1.5
- Date: August 2000
-
- Copyright © 1998-2000 Dan Wright, All rights reserved.
-
- Bugs?: Please include the name of this file, the version, and the date (above).
- Send bug reports to danwr@kagi.com.
-
- Updates: http://www.halcyon.com/danwr/smoothie.html
- */
-
- #ifndef __FRAZAPI__
- #define __FRAZAPI__
-
-
- #if PRAGMA_ONCE
- #pragma once
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT
- #pragma import on
- #endif
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
- #endif
-
-
- #ifndef FRAZ_OLDAPI
- #define FRAZ_OLDAPI 0
- #endif
-
- enum {
- #if TARGET_API_MAC_CARBON
- kFzecCurrentVersion = 2,
- kFzabCurrentVersion = 2,
- #else
- kFzecCurrentVersion = 0,
- kFzabCurrentVersion = 0,
- #endif
-
- kFragmalyzerSignature = FOUR_CHAR_CODE('FraZ'),
-
- kFrazCommandResourceType = FOUR_CHAR_CODE('Fzec'),
-
- kFrazCommandFileType = FOUR_CHAR_CODE('Fzec'),
-
- kFrazBFXResourceType = FOUR_CHAR_CODE('Fzab'),
-
- kFrazBFXFileType = FOUR_CHAR_CODE('Fzab'),
-
- kSigPluginActive = 0,
-
- kSigPluginNone = 0
- };
-
- #if FRAZ_OLDAPI
- enum {
- kFrazPluginFileType = kFrazCommandFileType,
- kFrazPluginResourceType = kFrazCommandResourceType,
- };
- #endif // FRAZ_OLDAPI
-
- /*
- Menu IDs
- */
- enum {
- kFrazMenuFile = 1001,
- kFrazMenuEdit,
- kFrazMenuFragmalyze,
- kFrazMenuSymbol,
-
- kFrazMenuUserMin = 2000,
- kFrazMenuUserMax = 2009,
-
-
- kFrazMenuBar = 0, /* menu id for adding menus to the menubar */
-
- kFrazCmdInsertAtDefaultLocation = 0 /* use with FrazInsertCommand for default behavior */
- };
-
-
- /*
- Command IDs
- */
- enum {
- kFrazCmdUndo = 11,
- kFrazCmdCut = 12,
- kFrazCmdCopy = 13,
- kFrazCmdPaste = 14,
- kFrazCmdClear = 15
- };
-
- /*
- ctEnableFlags
- - indicate conditions under which commands are enabled/disabled
- */
- enum {
- kctAlways = 0, /* always enabled */
- kctBrowser, /* requires active browser window */
- kctFragment, /* requires selected fragment */
- kctImportLibrary, /* requires selected import library */
- kctApplication, /* requires selected application fragment */
- kctReserved5, /* reserved for future use */
- kctReserved6, /* reserved for future use */
- kctPluginWindow, /* requires active plug-in window */
-
- kctImportSymbol = 8, /* requires that 1+ import symbols be selected */
- kctExportSymbol = 16, /* requires that 1+ export symbols be selected */
- kctSymbol = (kctImportSymbol | kctExportSymbol), /* any kind of symbol will do */
- kctExactlyOneSymbol = 32, /* requires that ONLY 1 symbol be selected */
-
- kctReservedx40 = 64,
-
- kctDoubleClickAction = 0x0080, /* can handle double-click */
-
- kctReservedx100 = 0x0100,
- kctReservedx200 = 0x200,
-
- kctWriteAccess = 0x0400, /* browser/fragment must be modifiable */
- kctProcess = 0x0800, /* context browsers only */
- kctNeedsCall = 0x1000, /* always call FindCommandStatus */
- kctCallEnabled = 0x2000, /* call FindCommandStatus only if command appears to be enabled (according to other conditions) */
-
- kctReservedx4000 = 0x4000,
- kctReservedx8000 = 0x8000,
-
- kctMaskGeneral = 0x1F
- };
-
-
- #ifdef __cplusplus
- inline Boolean IsStandardCommand(UInt32 cmd)
- {
- return (cmd & 0xFFFF0000) == 0;
- }
-
- inline UInt16 GetPluginCommandID(UInt32 cmd)
- {
- return IsStandardCommand(cmd) ? 0 : (cmd & 0x0000FFFF);
- }
-
- #define OPTIONAL_ =0
- #else
- #define GetPluginCommandID(cmd) ((cmd) & 0xFFFF)
- #define IsStandardCommand(cmd) (((cmd) & 0xFFFF0000) == 0)
-
- #define OPTIONAL_
- #endif
-
-
- /*——————————————————————————————————————————————————————————————
- O P A Q U E R E F E R E N C E S
- ——————————————————————————————————————————————————————————————*/
- typedef struct OpaqueBrowser *BrowserRef;
- typedef struct OpaqueFragment *FragmentRef;
- typedef struct OpaqueLibrary *LibraryRef;
-
- typedef struct OpaqueProgress *ProgressRef;
-
- typedef struct OpaquePlugin *PluginRef;
-
-
- /*——————————————————————————————————————————————————————————————
- F R A Z P A R A M
- ——————————————————————————————————————————————————————————————*/
- typedef struct FrazParam
- {
- WindowRef window; /* the active window */
- BrowserRef browser; /* the active browser (or browser being acted upon) */
- FragmentRef fragment; /* the selected fragment (or fragment " ") */
- LibraryRef library; /* the selected import library (or library " ") */
- DescType dtAE; /* for HandleAppleEvent, this is the eventID;
- FrazResolveDesc places the class of the object here. */
- UInt16 isymbol; /* used only by FrazResolveDesc (because selection can
- include more than one symbol). It is an export symbol
- iff libSelected == nil. */
- UInt16 _reserved; /* reserved for future use */
- } FrazParam;
-
-
-
- #if FRAZ_OLDAPI
- /*——————————————————————————————————————————————————————————————
- F R A Z F R A G M E N T I N F O
- ——————————————————————————————————————————————————————————————*/
- typedef struct FrazFragmentInfo
- {
- StringPtr pstName; /* [RO] name of fragment */
- CFragContextID context; /* [RO] 0/nil if on disk */
- CFragConnectionID conn; /* [RO] 0/nil if on disk */
-
- SInt32 dirAppLibraries; /* aliased directory in 'cfrg' (or 0) */
- SInt32 cbAppStack; /* application stack (or 0) */
- SInt32 updateLevel; /* base fragment (0) or update */
- CFragUsage usage; /* fragment usage (app, shared lib, plugin,...) */
- UInt8 padding;
-
- /* from PEF file header */
- UInt32 architectureID; /* PowerPC or 68k */
- UInt32 version;
- UInt32 timestamp;
- UInt32 oldDefVersion;
- UInt32 oldImpVersion;
- UInt32 currentVersion;
- } FrazFragmentInfo;
- #endif // FRAZ_OLDAPI
-
- /*——————————————————————————————————————————————————————————————
- F R A Z W I N D O W B O U N D S
- ——————————————————————————————————————————————————————————————*/
- typedef struct FrazWindowBounds
- {
- UInt16 widthMin;
- UInt16 heightMin;
- UInt16 widthMax;
- UInt16 heightMax;
- UInt16 widthIdeal;
- UInt16 heightIdeal;
- UInt32 reserved;
- } FrazWindowBounds;
-
-
- // kGeneralImportSymbols is not a real library, it is used for import symbols that are not
- // associated with any library.
- const LibraryRef kGeneralImportSymbols = (LibraryRef)'hack';
-
- enum {
- idxNil = 0,
- isymNil = -1
- };
-
-
- /*
- Application-level
- - informational, event-handling, command status, and browser-independent app features
- */
-
-
-
-
- pascal SInt32 FrazVersion(NumVersion *);
-
- pascal void FrazHandleEvent(EventRecord *);
-
- pascal void FrazDirtyCommandStatus(void);
-
- pascal OSErr FrazOpenContext(CFragContextID context);
-
- pascal OSErr FrazOpenProcess(ProcessSerialNumber *psn);
-
- pascal void FrazOpenFile(FSSpec *, Boolean fNewBrowser);
-
- pascal void FrazInsertCommand(UInt16 ctEnableFlags, UInt16 command, UInt16 mid, StringPtr stCommand, UInt32 insertBeforeCmd);
-
- pascal void FrazRemoveCommand(UInt32 command);
-
- pascal int FrazSetCommandKey(UInt16 command, UInt8 chKey, UInt8 modifiers);
-
-
-
- /*
- Browsers
- */
- pascal void FrazRefreshBrowser(BrowserRef);
-
- pascal FragmentRef FrazGetIndFragment(BrowserRef, UInt16 index);
-
- pascal void FrazFindLibrarySet(BrowserRef, Boolean fMinimal);
-
- pascal UInt16 FrazGetNextSelectedSymbol(BrowserRef, UInt16 indexLast);
-
- pascal UInt16 FrazGetNextSelectedFragment(BrowserRef, UInt16 indexLast);
-
-
- /*
- Fragments
- */
-
- pascal LibraryRef FrazGetIndLibrary(FragmentRef, UInt16 index);
-
- /* Introduced in version 1.5 */
-
- pascal OSErr FrazGetFragmentProperty(FragmentRef, DescType propertyTag, Size inBufferSize, void *pbuffer,
- DescType *outType OPTIONAL_, Size *outActualSize OPTIONAL_);
-
- pascal OSErr FrazGetSectionProperty(FragmentRef fragment, UInt16 index, DescType propertyTag, Size inBufferSize,
- void *pbuffer, DescType *outType OPTIONAL_, Size *outActualSize OPTIONAL_);
-
- #if FRAZ_OLDAPI
- /* Deprecated; use FrazGetFragmentProperty instead */
- pascal void FrazGetFragmentInfo(FragmentRef, FrazFragmentInfo *pinfo);
-
- pascal void FrazSetFragmentInfo(FragmentRef, FrazFragmentInfo *pinfo);
- #endif // FRAZ_OLDAPI
-
- /*
- Libraries
- */
-
- pascal int FrazFindLibraryFragments(LibraryRef, FragmentRef *rgfrag, int cfragMax);
-
- #if FRAZ_OLDAPI
- pascal void FrazGetLibraryInfo(LibraryRef, UInt32 *poldImpVersion, UInt32 *pCurrentVersion, UInt8 *pOptions, StringPtr pstName);
- #endif // FRAZ_OLDAPI
-
- /* Introduced in version 1.5 */
-
- pascal OSErr FrazGetLibraryProperty(LibraryRef, DescType propertyTag, void *, Size, DescType * OPTIONAL_, Size * OPTIONAL_);
-
-
- /*
- Symbols
- */
- pascal OSErr FrazGetSymbolInfo(FragmentRef, LibraryRef, UInt16 index, StringPtr st255, Boolean *pfWeak);
-
- pascal void FrazUnmangleSymbol(StringPtr inStMangled, StringPtr outStUnmangled);
-
- /* Introduced in version 1.5 */
-
- pascal OSErr FrazGetSymbolProperty(FragmentRef, LibraryRef, UInt32 isym, OSType property, void *, Size, DescType * OPTIONAL_, Size * OPTIONAL_);
-
-
- /*
- Plug-in Windows
- Claim ownership of a modeless window/dialog. Events will be sent to the plug-in's FilterEvent
- and HandleCloseWindow entrypoints.
- */
-
- #if TARGET_API_MAC_CARBON
- /* Modified for version 2.0 */
-
- pascal void FrazMarkPluginWindow(PluginRef, WindowPtr);
-
- #else
-
- pascal void FrazMarkPluginWindow(WindowPtr);
-
- #endif
-
- /*
- AppleEvents
-
- Routines for creating/resolved AppleEvent objects, and for manipulating properties.
- */
-
- /* The object class is returned in param->dtAE. Be aware that FrazResolveDesc
- may not return the same class every time -- so be sure to check param->dtAE.
- The superobjects are also filled in. This is the only case where isymbol may
- be filled in. */
- pascal OSErr FrazResolveDesc(AEDesc *inObject, FrazParam *param);
-
- pascal OSErr FrazMakeObject(FrazParam *param, DescType inClass, AEDesc *outObject);
-
- /* FrazAESetProperty buillds a "set data" AppleEvent and sends it to the Fragmalyzer (send to self).
- This will record the action (if recording is on), and will cause the action to be executed. */
- #define FrazAESetProperty FrazSetProperty
- pascal OSErr FrazAESetProperty(FrazParam *param, DescType inClass, DescType inProperty, AEDesc *inValue);
-
-
-
- /*
- Status/Progress reports
- */
-
- pascal ProgressRef FrazShowProgress(StringPtr stTitle, StringPtr stLine1, Boolean fIndeterminate);
-
- pascal void FrazSetProgressText(ProgressRef, StringPtr stLine1, StringPtr stLine2); /* use nil if no change */
-
- pascal Boolean FrazUpdateProgress(ProgressRef, SInt32 percentDone /* ignored if fIndeterminate */);
-
- pascal void FrazCloseProgress(ProgressRef, Boolean fDone);
-
-
-
- /*
- Alerts/messages
- - use instead of StopAlert, NoteAlert, and CautionAlert
- */
-
- pascal void FrazStopAlert(StringPtr stMain, StringPtr stAlt);
-
- pascal void FrazNoteAlert(StringPtr stMain, StringPtr stAlt);
-
- pascal SInt32 FrazCautionAlert(StringPtr stMain, StringPtr stAlt);
-
-
-
- /*
- Plug-ins
- */
-
- pascal Boolean FrazGetPluginInfo(OSType sigPlugin, FSSpec *, UInt16 *pVers);
-
- pascal Boolean FrazPluginObeyCommand(OSType sigPlugin, UInt16 cmd, FrazParam *);
-
- /* Introduced in version 1.5 */
-
- /*
- FrazEnterPlugin/FrazLeavePlugin
- - wrap custom entrypoints with these calls to ensure that the plugin is not
- unloaded while its code is on the stack (this could happen if memory is sufficently
- low, triggering the growZone proc).
-
- These calls must be balanced.
- */
- #if TARGET_API_MAC_CARBON
- pascal void FrazEnterPlugin(PluginRef);
- pascal void FrazLeavePlugin(PluginRef);
- #else
- pascal void FrazEnterPlugin(void);
- pascal void FrazLeavePlugin(void);
- #endif
-
- /*
- The Entrypoints
-
- Boolean ObeyCommand(UInt32 inCommand, FrazParam *param);
- void FindCommandStatus(UInt32 inCmd, FrazParam *param, Boolean &outEnabled, Boolean &outUsesMark, UInt16 &outMark, Str255 &outName);
- OSErr HandleAppleEvent(const AppleEvent *, AppleEvent *, FrazParam *param);
- Boolean FilterEvent(EventRecord *);
- Boolean HandleCloseWindow(WindowRef, Boolean fCanInteract);
- void SetWindowSize(WindowRef, short width, short height);
- void GetWindowLimits(WindowRef, FrazWindowBounds *);
-
- OSStatus InitPlugin(PluginRef, long reserved);
- */
-
- extern PluginRef gPluginSelf;
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack()
- #endif
-
- #ifdef PRAGMA_IMPORT_OFF
- #pragma import off
- #elif PRAGMA_IMPORT
- #pragma import reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #ifdef __cplusplus
- class StCustomEntrypoint
- {
- public:
- #if TARGET_API_MAC_CARBON
- StCustomEntrypoint() { FrazEnterPlugin(gPluginSelf); };
- virtual ~StCustomEntrypoint() { FrazLeavePlugin(gPluginSelf); };
- #else
- StCustomEntrypoint() { FrazEnterPlugin(); }
- virtual ~StCustomEntrypoint() { FrazLeavePlugin(); }
- #endif
- };
- #endif // __cplusplus
-
- #endif /* __FRAZAPI__ */